package com.chuangsi.project.admin.service.impl;


import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.chuangsi.common.utils.MyStringUtils;
import com.chuangsi.project.admin.domain.Brand;
import com.chuangsi.project.admin.dto.admin.brand.ReqBrandPageDto;
import com.chuangsi.project.admin.dto.admin.brand.ReqBrandUpdateDto;
import com.chuangsi.project.admin.dto.admin.brand.ResBrandPageDto;
import com.chuangsi.project.admin.dto.common.SelectDto;
import com.chuangsi.project.admin.mapper.BrandMapper;
import com.chuangsi.project.admin.service.BrandService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 品牌表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-03-23
 */
@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {

    @Override
    public List<ResBrandPageDto> brandPage(ReqBrandPageDto req) {
        return baseMapper.brandPage(req);
    }

    @Override
    public Map<String, String> getBrandMap() {
        return list().stream().collect(Collectors.toMap(Brand::getBrandId,Brand::getBrandName));
    }

    @Override
    public List<SelectDto> brandSelect() {
        return list().stream().map(x->new SelectDto(x.getBrandId(),x.getBrandName())).collect(Collectors.toList());
    }
}
